bag={'a':5,'d':3}
items=['a','g','k']

def displayInventory(dic):
  print('Inventory:')
  tni=0
  for i in dic.keys():
    print(str(dic[i])+' '+i)
    tni+=dic[i]
  print('Total number of items: '+str(tni))

def addToInventory(inventory,addedItems):
  for i in addedItems:
    if i in inventory:
      inventory[i]+=1
    else:
      inventory.setdefault(i,1)
addToInventory(bag,items)
displayInventory(bag)
